<?php

namespace App\Http\Requests\User\Personal;

use Illuminate\Support\Facades\Auth;
use Illuminate\Validation\Rule;
use Illuminate\Foundation\Http\FormRequest;

class ModifyIdentification extends FormRequest
{
    /**
     * Determine if the user is authorized to make this request.
     *
     * @return bool
     */
    public function authorize()
    {
        return true;
    }

	/**
	 * 定义表单验证规则
	 *
	 * Date: 11/04/2018
	 * @author George
	 * @return array
	 */
    public function rules()
    {
    	$user = Auth::user();
        return [
			'name' => 'required',
			'birthday' => 'required',
			'gender' => 'required',
			'identification' => [
				'required',
				Rule::unique('users')->ignore($user->id)
			],
			'issuer' => 'required',
			'hometown' => 'required',
			'identification_front' => 'required',
			'identification_reverse' => 'required',
		];
    }

	/**
	 * 定义表单验证错误信息
	 *
	 * Date: 11/04/2018
	 * @author George
	 * @return array
	 */
	public function messages()
	{
		return [
			'name.required' => '请输入姓名',
			'birthday.required' => '请输入生日',
			'gender.required' => '请输入性别',
			'identification.required' => '请输入身份证号码',
			'identification.unique' => '身份证号已存在',
			'issuer.required' => '请输入签发机关',
			'hometown.required' => '请输入户籍地址',
			'identification_front.required' => '请上传身份证正面照片',
			'identification_reverse.required' => '请上传身份证反面照片',
		];
    }
}
